package day_2022_4_to_7.day48;

import java.util.Scanner;

/**
 * @author haomin
 * @date 2022/04/21 09:20
 **/

public class Day4_2_BinaryConversion {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int m = in.nextInt();
        if(m == 0){
            System.out.print("0");
            return;
        }
        int n = in.nextInt();
        boolean flag = false;
        if(m < 0){
            flag = true;
            m = - m;
        }
        char[] arr = new char[1000];
        int i = 0;
        while(m != 0){
            int result = (m % n);
            if(result > 9){
                arr[i] = (char)(result + 'A' - 10);
            }else {
                arr[i] = (char)(result + '0');
            }
            m = m / n;
            i++;
        }
        if(flag){
            System.out.print("-");
        }
        for (int j = i-1; j >=0 ; j--) {
            System.out.print(arr[j]);
        }
    }
}